1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package net.sf.webphotos.gui;
17
18 import javax.swing.*;
19 import net.sf.webphotos.action.AcaoPopup;
20 import net.sf.webphotos.util.Util;
21
22
23
24
25
26
27 public class PopupMenu extends JPopupMenu {
28 private String preSQL="select albumID as ID, categorias.nmcategoria as Categoria, nmalbum as Pauta, DATE_FORMAT(DtInsercao, '%d/%m/%y') as Data from albuns left join categorias using(categoriaID) ";
29
30
31
32
33
34 public PopupMenu() {
35 String posSQL;
36 int ct=1;
37
38 while((posSQL=Util.getConfig().getString("relatorio" + ct++))!=null) {
39 int pos=posSQL.indexOf('/');
40 String nomeComando=posSQL.substring(0,pos).trim();
41 String comando=posSQL.substring(pos+1).trim();
42
43 JMenuItem menuItem=new JMenuItem(nomeComando, new ImageIcon(getClass().getResource("/icons/pontoazul.gif")));
44
45 menuItem.addActionListener(new AcaoPopMenu(comando));
46 this.add(menuItem);
47 }
48
49 }
50
51
52
53
54
55
56
57 public static void main(String[] a) {
58 PopupMenu t=new PopupMenu();
59 JFrame f=new JFrame();
60 f.getContentPane().setLayout(null);
61
62 JButton bt=new JButton("teste");
63 bt.setBounds(20,20,100,25);
64 bt.addMouseListener(new AcaoPopup((JPopupMenu) t));
65 f.getContentPane().add(bt);
66
67
68 f.setSize(200,200);
69 f.getContentPane().add(t);
70
71 f.setVisible(true);
72 }
73
74
75
76
77
78 public String getPreSQL() {
79 return preSQL;
80 }
81
82
83
84
85
86 public void setPreSQL(String preSQL) {
87 this.preSQL = preSQL;
88 }
89
90 }